//观察者

function ObserverList(){
	this.observerList=[];
}
//添加
ObserverList.prototype.Add=function(obj){
	return this.observerList.push(obj)
};
//清空
ObserverList.prototype.Empty=function(){
	this.observerList=[];
};
//获取长度
ObserverList.prototype.Count=function(){
	return this.observerList.length;
};
//获取当前对象
ObserverList.prototype.Get=function(index){
	if(index>-1 && index<this.observerList.length){
		return this.observerList[index];
	}
};
//插入最前或最后
ObserverList.prototype.Insert=function(obj,index){
	var pointer=-1;
	if(index===0){
		this.observerList.unshift(obj);
		pointer=index;
	}else if (index===this.observerList.length){
		this.observerList.push(obj);
		pointer=index;
	}

	return pointer;
};

ObserverList.prototype.IndexOf=function(obj,startIndex){
	var i=startIndex, pointer=-1;
	while(i<this.observerList.length){
		if(this.observerList[i]==obj){
			pointer=i;
		}
		i++;
	}
	return pointer;
};

ObserverList.prototype.RemoveIndexAt=function(index){
	if(index==0){
		this.observerList.shift();
	}else if(index==this.observerList.length-1){
		this.observerList.pop();
	}
};

//使用extension扩展对象
function extend(obj,extension){
	for(var key in obj){
		extension[key]=obj[key];
	}
}